#ifndef BONDERDISPATCHER_H
#define BONDERDISPATCHER_H

#include "../WorkerRepos/PressureMonitor/pressuremonitor.h"
#include "BasicElement/basicelementfactory.h"
#include "Laser/htg1laser.h"
#include "VisionManager/visionmanager.h"
#include "bonderbasicconfig.h"
#include "mastermotionmanager.h"
#include "systemCore/dispatcher.h"
#include "uphhelper.h"
#include "workers/BonderHead/bonderhead.h"
#include "workers/BonderWorkHolder/bonderworkholder.h"
#include "workers/BonderWorkHolder/sensortrayconveyer.h"
#include "workers/DispenseModule/dispensehead.h"
#include "workers/DispenseModule/dispenseworkholder.h"
#include "workers/LensTrayModule/lenstrayloader.h"
#include "workers/SensorTrayElevator/sensortrayinputelevator.h"
#include "workers/SensorTrayElevator/sensortrayoutputelevator.h"
#include <QObject>
#include <QQmlApplicationEngine>
#include <QQmlContext>

class BonderDispatcher : public Dispatcher
{
    Q_OBJECT
public:
    explicit BonderDispatcher(MasterMotionManager *masterMotionManager,
                              BonderBasicConfig *bonderBasicConfig,
                              BasicElementFactory *motionElementFactory);

    void setContextProperty(QQmlApplicationEngine &engine);

    // Dispatcher interface
protected:
    virtual void handleInit() override;
    virtual void handleStart() override;
    virtual void handlePause() override;
    virtual void handleContinue() override;
    virtual void handleAbort() override;
    virtual void handleReset() override;
    virtual void preHome() override;
    virtual void postHome() override {}

private:
    UPHHelper *uphHelper;

    MasterMotionManager *masterMotionManager;
    BonderBasicConfig *bonderBasicConfig;
    BasicElementFactory *motionElementFactory;

    SensorTrayInputElevator *stie = nullptr;
    SensorTrayOutputElevator *stoe = nullptr;
    SensorTrayElevatorConfig *steConfig = nullptr;
    ConfigFile *steConfigFile = nullptr;

    ConfigFile *whStateStoreFile;
    WorkHolderState *whState;

    LaserConfig *laserConfig;
    ConfigFile *laserConfigFile;
    LaserDriver *laserDriver;
    HTG1Laser *leftLaser;
    HTG1Laser *rightLaser;
    DispenseHeadCommonConfig *dispCommonConfig;
    ConfigFile *dispCommonConfigFile;
    DispenseHead *leftDispHead;
    DispenseHead *rightDispHead;
    DispenseWorkHolder *dispWorkHolder;
    TrayConfig *sensorTrayConfig;
    ConfigFile *sensorTrayConfigFile;
    SensorTrayMap *sensorTrayMap;

    BonderWorkHolder *bonderWorkHolder;
    SensorTrayConveyer *sensorTrayConveyer;

    LensTrayModuleConfig *ltModuleConfig;
    ConfigFile *ltModuleConfigFile;
    LensTrayModuleState *ltModuleState;
    ConfigFile *ltModuleStateStoreFile;
    TrayConfig *lensTrayConfig;
    ConfigFile *lensTrayConfigFile;
    LensTrayMap *lensTrayMap;
    LensTrayMagazine *lensTrayMagazine;
    LensTrayBuffer *lensTrayBuffer;
    LensTrayLoader *lensTrayLoader;

    BonderHead *bonderHead;

    PressureMonitor *pressureMonitor;
};

#endif    // BONDERDISPATCHER_H
